Release 10.1A: OpenEdge Development:
.NET Open Clients


Temp-table examples

This section provides some code examples for temp-tables.

Note: These samples are not available on the Documentation and Samples CD or Progress Documentation Web site.

Sample static temp-table

Example 4–1 is a static temp-table definition in a persistent procedure, PaymentInfo.p.

Example 4–1: Static temp-table in a persistent procedure
DEFINE TEMP-TABLE PaymentInfoTT 
     FIELD payment-date   AS DATE 
     FIELD payee-id       AS INTEGER 
     FIELD payee-name     AS CHAR 
     FIELD amount         AS DECIMAL 
     FIELD cleared        AS LOGICAL. 
PROCEDURE getPaymentsInfo: 
          DEFINE INPUT PARAM fromDate AS DATE. 
          DEFINE OUTPUT PARAM TABLE FOR PaymentInfoTT. 

For this parameter, ProxyGen generates the following:

Example 4–2 is a static temp-table definition in an external procedure, setPaymentInfo.p.

Example 4–2: Static temp-table in an external procedure
DEFINE TEMP-TABLE MySetPaymentInfoTT 
     FIELD payment-date   AS DATE 
     FIELD payee-id       AS INTEGER 
     FIELD payee-name     AS CHAR 
     FIELD amount         AS DECIMAL 
     FIELD cleared        AS LOGICAL. 
DEFINE INPUT PARAM TABLE FOR MySetPaymentInfoTT. 

Since the schema for these two static temp-table parameters is the same, ProxyGen uses the previously generated, strongly typed DataTable in the proxy method generated for this external procedure:

public void setPaymentInfo(System.DateTime fromDate, 
        out Acme.StrongTypesNS.PaymentInfoTTDataTable MySetPaymentInfoTT) 

For INPUT and INPUT-OUTPUT parameters, the .NET client code must supply an instance of the strongly typed DataTable object. For OUTPUT parameters, the strongly typed DataTable variable must be declared, but the instance is created by Progress and returned to the .NET client.

Sample TABLE-HANDLE parameter

Example 4–3 is a TABLE-HANDLE parameter.

Example 4–3: TABLE-HANDLE parameter
PROCEDURE getOrderInfo: 
     DEFINE INPUT PARAMETER TABLE-HANDLE tth1. 

For this parameter, ProxyGen generates the following method in the proxy:

public void getOrderInfo(System.Data.DataTable tth1) 

For INPUT and INPUT-OUTPUT parameters, the .NET client code must supply an instance of the System.Data.DataTable object, a strongly typed DataTable, or the Progress.Open4GL.ProDataTable. For OUTPUT parameters, the DataTable variable must be declared, but the instance is created by Progress and returned to the .NET client.

Sample .NET Open Client application using a temp-table

Example 4–4 and Example 4–5 show sample code for calling a procedure with a temp-table.

Example 4–4: Calling a procedure with an output dynamic temp-table
// Calling a procedure with an output dynamic temp-table. 
Account appObj = new Account("AppServer://myhost/asbroker1", "", "", ""); 
System.Data.DataTable outDT = null; 
// Call the procedure 
appObj.GetTTOut(out outDT); 
// Run through the Progress DataTable. First output the schema. 
int numCols = outDT.Columns.Count; 
for (int ix = 0; ix < numCols; ix++) 
{ 
   System.Console.WriteLine(outDT.Columns[ix].ColumnName + " " + 
      outDT.Columns[ix].DataType.ToString()); 
} 
// Output the data. 
foreach (DataRow dr in outDT.Rows) 
// Print the first column in the row. 
{ 
   System.Console.WriteLine(“ Column 1 “ + dr.Columns[0]); 
} 

Example 4–5: Calling a procedure with an input dynamic temp-table
// Calling a procedure with an input dynamic temp-table. 
// The Progress DataTable has 2 columns, integer and string. 
Account appObj = new Account("AppServer://myhost/asbroker1", "", "", ""); 
System.Data.DataTable inDT = new System.Data.DataTable(); 
inDT.Columns.Add("acctnum", typeof(int)); 
inDT.Columns.Add("Name", typeof(string)); 
DataRow testRow; 
// Add 3 rows of data. 
for (int i = 1; i <= 3; i++) 
{ 
   testRow = inDT.NewRow(); 
   testRow[0] = i; 
   testRow[1] = "Test String " + i.ToString(); 
   inDT.Rows.Add(testRow); 
} 
// Call the procedure 
appObj.SetTTIn(inDT); 


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095